home *** CD-ROM | disk | FTP | other *** search
/ Over 1,000 Windows 95 Programs / Over 1000 Windows 95 Programs (Microforum) (Disc 1).iso / 1471 / frmmain.frm (.txt) < prev    next >
Visual Basic Form  |  1997-02-11  |  15KB  |  472 lines

  1. VERSION 4.00
  2. Begin VB.Form frmMain 
  3.    Caption         =   "ThreadView Sample Application"
  4.    ClientHeight    =   5784
  5.    ClientLeft      =   3612
  6.    ClientTop       =   1896
  7.    ClientWidth     =   6552
  8.    Height          =   6168
  9.    Left            =   3564
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   5784
  12.    ScaleWidth      =   6552
  13.    Top             =   1560
  14.    Width           =   6648
  15.    Begin VB.PictureBox picCmdCenter 
  16.       Height          =   828
  17.       Left            =   96
  18.       ScaleHeight     =   780
  19.       ScaleWidth      =   6300
  20.       TabIndex        =   4
  21.       Top             =   2940
  22.       Visible         =   0   'False
  23.       Width           =   6348
  24.       Begin VB.TextBox txtSelect 
  25.          Height          =   288
  26.          Left            =   4128
  27.          TabIndex        =   14
  28.          Text            =   "1"
  29.          Top             =   60
  30.          Width           =   588
  31.       End
  32.       Begin VB.TextBox txtDeselect 
  33.          Height          =   288
  34.          Left            =   4128
  35.          TabIndex        =   13
  36.          Text            =   "1"
  37.          Top             =   420
  38.          Width           =   588
  39.       End
  40.       Begin VB.CommandButton cmdDeselect 
  41.          Caption         =   "Deselect"
  42.          Height          =   312
  43.          Left            =   4824
  44.          TabIndex        =   12
  45.          Top             =   408
  46.          Width           =   1152
  47.       End
  48.       Begin VB.CommandButton cmdCollapseAll 
  49.          Caption         =   "Collapse All"
  50.          Height          =   312
  51.          Left            =   2340
  52.          TabIndex        =   11
  53.          Top             =   420
  54.          Width           =   1152
  55.       End
  56.       Begin VB.CommandButton cmdExpandAll 
  57.          Caption         =   "Expand All"
  58.          Height          =   312
  59.          Left            =   2328
  60.          TabIndex        =   10
  61.          Top             =   72
  62.          Width           =   1152
  63.       End
  64.       Begin VB.CommandButton cmdSelect 
  65.          Caption         =   "Select"
  66.          Height          =   312
  67.          Left            =   4824
  68.          TabIndex        =   9
  69.          Top             =   48
  70.          Width           =   1152
  71.       End
  72.       Begin VB.TextBox txtCollapse 
  73.          Height          =   288
  74.          Left            =   48
  75.          TabIndex        =   8
  76.          Text            =   "1"
  77.          Top             =   420
  78.          Width           =   588
  79.       End
  80.       Begin VB.CommandButton cmdCollapse 
  81.          Caption         =   "Collapse"
  82.          Height          =   312
  83.          Left            =   732
  84.          TabIndex        =   7
  85.          Top             =   408
  86.          Width           =   1152
  87.       End
  88.       Begin VB.TextBox txtExpand 
  89.          Height          =   288
  90.          Left            =   48
  91.          TabIndex        =   6
  92.          Text            =   "1"
  93.          Top             =   72
  94.          Width           =   588
  95.       End
  96.       Begin VB.CommandButton cmdExpand 
  97.          Caption         =   "Expand"
  98.          Height          =   312
  99.          Left            =   732
  100.          TabIndex        =   5
  101.          Top             =   60
  102.          Width           =   1152
  103.       End
  104.    End
  105.    Begin VB.TextBox Text1 
  106.       Height          =   1392
  107.       Left            =   540
  108.       Locked          =   -1  'True
  109.       MultiLine       =   -1  'True
  110.       TabIndex        =   3
  111.       Top             =   3756
  112.       Visible         =   0   'False
  113.       Width           =   5748
  114.    End
  115.    Begin VB.PictureBox picHeader 
  116.       Appearance      =   0  'Flat
  117.       AutoSize        =   -1  'True
  118.       BackColor       =   &H80000005&
  119.       BorderStyle     =   0  'None
  120.       ForeColor       =   &H80000008&
  121.       Height          =   444
  122.       Left            =   390
  123.       Picture         =   "frmMain.frx":0000
  124.       ScaleHeight     =   444
  125.       ScaleWidth      =   4620
  126.       TabIndex        =   0
  127.       TabStop         =   0   'False
  128.       Top             =   30
  129.       Width           =   4620
  130.    End
  131.    Begin ThreadViewAX.ThreadView ThreadView1 
  132.       Height          =   1248
  133.       Left            =   1116
  134.       TabIndex        =   15
  135.       Top             =   1188
  136.       Width           =   4464
  137.       _ExtentX        =   7874
  138.       _ExtentY        =   2201
  139.       BorderStyle     =   1
  140.       ColumnCount     =   0
  141.    End
  142.    Begin ComctlLib.ImageList ImageList1 
  143.       Left            =   2796
  144.       Top             =   2652
  145.       _Version        =   65536
  146.       _ExtentX        =   804
  147.       _ExtentY        =   804
  148.       _StockProps     =   1
  149.       BackColor       =   -2147483643
  150.       ImageWidth      =   16
  151.       ImageHeight     =   16
  152.       MaskColor       =   128
  153.       NumImages       =   7
  154.       i1              =   "frmMain.frx":3C56
  155.       i2              =   "frmMain.frx":3E11
  156.       i3              =   "frmMain.frx":3FCC
  157.       i4              =   "frmMain.frx":4187
  158.       i5              =   "frmMain.frx":433E
  159.       i6              =   "frmMain.frx":44F9
  160.       i7              =   "frmMain.frx":46B4
  161.    End
  162.    Begin ComctlLib.StatusBar StatusBar1 
  163.       Align           =   2  'Align Bottom
  164.       Height          =   300
  165.       Left            =   0
  166.       TabIndex        =   2
  167.       Top             =   5484
  168.       Width           =   6552
  169.       _Version        =   65536
  170.       _ExtentX        =   11557
  171.       _ExtentY        =   529
  172.       _StockProps     =   68
  173.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  174.          Name            =   "MS Sans Serif"
  175.          Size            =   7.8
  176.          Charset         =   204
  177.          Weight          =   400
  178.          Underline       =   0   'False
  179.          Italic          =   0   'False
  180.          Strikethrough   =   0   'False
  181.       EndProperty
  182.       AlignSet        =   -1  'True
  183.       SimpleText      =   ""
  184.       i1              =   "frmMain.frx":4BAF
  185.    End
  186.    Begin ComctlLib.TabStrip TabStrip1 
  187.       Height          =   4776
  188.       Left            =   48
  189.       TabIndex        =   1
  190.       Top             =   588
  191.       Width           =   6468
  192.       _Version        =   65536
  193.       _ExtentX        =   11409
  194.       _ExtentY        =   8424
  195.       _StockProps     =   68
  196.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  197.          Name            =   "MS Sans Serif"
  198.          Size            =   7.8
  199.          Charset         =   204
  200.          Weight          =   400
  201.          Underline       =   0   'False
  202.          Italic          =   0   'False
  203.          Strikethrough   =   0   'False
  204.       EndProperty
  205.       ImageList       =   ""
  206.       NumTabs         =   3
  207.       i1              =   "frmMain.frx":4CBB
  208.       i2              =   "frmMain.frx":4E02
  209.       i3              =   "frmMain.frx":4F4D
  210.    End
  211.    Begin VB.Menu mnuPopup 
  212.       Caption         =   "PopUp"
  213.       Visible         =   0   'False
  214.       Begin VB.Menu mnuExpand 
  215.          Caption         =   "Expand"
  216.       End
  217.       Begin VB.Menu mnuCollapse 
  218.          Caption         =   "Collapse"
  219.       End
  220.    End
  221.    Begin VB.Menu mnuHeader 
  222.       Caption         =   "HeaderPopUp"
  223.       Visible         =   0   'False
  224.       Begin VB.Menu mnuSortAsc 
  225.          Caption         =   "Sort Ascending"
  226.       End
  227.       Begin VB.Menu mnuSortDesc 
  228.          Caption         =   "Sort Descending"
  229.       End
  230.    End
  231. Attribute VB_Name = "frmMain"
  232. Attribute VB_Creatable = False
  233. Attribute VB_Exposed = False
  234. Option Explicit
  235. Dim FileSys As clscFileSysItems
  236. Dim Contacts As clscContacts
  237. Dim Messages As clscMessages
  238. Dim pnlMsg As Panel
  239. Dim lngCurSect As Long
  240. 'This sub reads data from Access database and
  241. 'loads it into ThreadView control
  242. Private Sub DiscussionsTree()
  243. With ThreadView1
  244.     .Frozen = True 'Always use frozen!
  245.     'You can also add or remove columns at design-time
  246.     'using property page
  247.     With .Columns
  248.            .Clear
  249.         .Add "Subject", "Subject", 200, vbLeftJustify
  250.         .Add "Sender", "Author", 80, vbLeftJustify
  251.         .Add "DateSent", "Date", 80, vbRightJustify
  252.     End With
  253.     .SortColumn = 1
  254.     Set .ImageList = ImageList1
  255.     'if object with data isn't initialized, do it now
  256.     If Messages Is Nothing Then
  257.         MousePointer = vbHourglass
  258.         pnlMsg = "Loading Jet and retrieving data ..."
  259.         DoEvents 'give status bar time to repaint itself
  260.         Set Messages = New clscMessages
  261.         Messages.Create
  262.     End If
  263.     Set .UserObject = Messages
  264.     .Frozen = False
  265.     MousePointer = vbDefault
  266.     pnlMsg = "Ready"
  267. End With
  268. Text1.Visible = True
  269. picCmdCenter.Visible = False
  270. End Sub
  271. 'This sub reads your drive information and
  272. 'loads it into ThreadView control
  273. Private Sub FileSysTree()
  274. 'Hides/shows controls
  275. Text1.Visible = False
  276. picCmdCenter.Visible = False
  277. With ThreadView1
  278.     .Frozen = True 'Always use frozen!
  279.     'You can also add or remove columns at design-time
  280.     'using property page
  281.     With .Columns
  282.         .Clear
  283.         .Add "Name", "Folder/File Name", 200, vbLeftJustify
  284.         .Add "Size", "Size In Bytes", 80, vbRightJustify
  285.         .Add "DateModified", "Date Of Last Modification", 80, vbRightJustify
  286.     End With
  287.     .SortColumn = 1
  288.     Set .ImageList = ImageList1
  289.     'if object with data isn't initialized, do it now
  290.     If FileSys Is Nothing Then
  291.         MousePointer = vbHourglass
  292.         pnlMsg = "Reading your drive information..."
  293.         DoEvents 'give status bar time to repaint itself
  294.         Set FileSys = New clscFileSysItems
  295.         FileSys.Create "c:\"
  296.     End If
  297.     Set .UserObject = FileSys
  298.     .Frozen = False
  299. End With
  300. MousePointer = vbDefault
  301. pnlMsg = "Ready"
  302. End Sub
  303. 'This sub reads data from Access database and
  304. 'loads it into ThreadView control
  305. Private Sub ContactsTree()
  306. Text1.Visible = False
  307. picCmdCenter.Visible = True
  308. With ThreadView1
  309.     .Frozen = True 'Always use frozen
  310.     'You can also add or remove columns at design-time
  311.     'using property page
  312.     With .Columns
  313.         .Clear
  314.         .Add "Name", "Contact Name", 200, vbLeftJustify
  315.         .Add "WorkPhone", "Work Phone", 80, vbRightJustify
  316.         .Add "LastMeetingDate", "Last Meeting Date", 80, vbRightJustify
  317.     End With
  318.     .SortColumn = 1
  319.     Set .ImageList = ImageList1
  320.     'if object with data isn't initialized, do it now
  321.     If Contacts Is Nothing Then
  322.         MousePointer = vbHourglass
  323.         pnlMsg = "Loading Jet and retrieving data ..."
  324.         DoEvents 'give status bar time to repaint itself
  325.         Set Contacts = New clscContacts
  326.         Contacts.Create
  327.     End If
  328.     Set .UserObject = Contacts
  329.     .Frozen = False
  330. End With
  331. MousePointer = vbDefault
  332. pnlMsg = "Ready"
  333. End Sub
  334. Private Sub cmdCollapse_Click()
  335. ThreadView1.ThreadLines(txtCollapse).Expanded = False
  336. End Sub
  337. Private Sub cmdCollapseAll_Click()
  338. Dim i As Long
  339. ThreadView1.Frozen = True
  340.     i = i + 1
  341.     ThreadView1.ThreadLines(i).Expanded = False
  342. Loop While ThreadView1.ThreadLines.Count > i
  343. ThreadView1.Frozen = False
  344. End Sub
  345. Private Sub cmdExpand_Click()
  346. ThreadView1.ThreadLines(txtExpand).Expanded = True
  347. End Sub
  348. Private Sub cmdExpandAll_Click()
  349. Dim i As Long
  350. ThreadView1.Frozen = True
  351.     i = i + 1
  352.     ThreadView1.ThreadLines(i).Expanded = True
  353. Loop While ThreadView1.ThreadLines.Count > i
  354. ThreadView1.Frozen = False
  355. End Sub
  356. Private Sub cmdSelect_Click()
  357. ThreadView1.ThreadLines(txtSelect).Selected = True
  358. End Sub
  359. Private Sub cmdDeselect_Click()
  360. ThreadView1.ThreadLines(txtDeselect).Selected = False
  361. End Sub
  362. Private Sub Form_Load()
  363. Set pnlMsg = statusbar1.Panels(1)
  364. FileSysTree
  365. End Sub
  366. Private Sub Form_Resize()
  367. If WindowState = vbMinimized Then Exit Sub
  368. With TabStrip1
  369.     .Width = ScaleWidth - 100
  370.     .Height = ScaleHeight - 1000
  371. End With
  372. With Text1
  373.     If .Visible Then
  374.         .Left = TabStrip1.ClientLeft
  375.         .Width = TabStrip1.ClientWidth
  376.         .Top = TabStrip1.ClientTop + TabStrip1.ClientHeight / 2
  377.         .Height = TabStrip1.ClientHeight / 2
  378.         
  379.     End If
  380. End With
  381. With picCmdCenter
  382.     If .Visible Then
  383.         .Top = TabStrip1.ClientTop + TabStrip1.ClientHeight - .Height
  384.         .Width = TabStrip1.ClientWidth
  385.     End If
  386. End With
  387. With ThreadView1
  388.     'Always set Frozen to True before making a number of changes
  389.     .Frozen = True
  390.     .Left = TabStrip1.ClientLeft
  391.     .Top = TabStrip1.ClientTop
  392.     .Width = TabStrip1.ClientWidth
  393.     Select Case TabStrip1.SelectedItem.Key
  394.         Case "Contacts" 'Contacts
  395.             .Height = TabStrip1.ClientHeight - picCmdCenter.Height
  396.         Case "Discussions" 'Discussions
  397.             .Height = TabStrip1.ClientHeight / 2
  398.         Case Else
  399.             .Height = TabStrip1.ClientHeight
  400.     End Select
  401.     .Frozen = False
  402. End With
  403. picHeader.Left = (ScaleWidth - picHeader.Width) / 2
  404. End Sub
  405. Private Sub mnuCollapse_Click()
  406. ThreadView1.SelectedItem.Expanded = False
  407. End Sub
  408. Private Sub mnuExpand_Click()
  409. ThreadView1.SelectedItem.Expanded = True
  410. End Sub
  411. Private Sub mnuSortAsc_Click()
  412. ThreadView1.SortColumn = lngCurSect
  413. ThreadView1.SortOrder = thvSortAsc
  414. End Sub
  415. Private Sub mnuSortDesc_Click()
  416. ThreadView1.SortColumn = lngCurSect
  417. ThreadView1.SortOrder = thvSortDesc
  418. End Sub
  419. Private Sub TabStrip1_Click()
  420. Select Case TabStrip1.SelectedItem.Key
  421.     Case "FileSys": FileSysTree
  422.     Case "Contacts": ContactsTree
  423.     Case "Discussions": DiscussionsTree
  424. End Select
  425. Form_Resize
  426. End Sub
  427. Private Sub ThreadView1_Collapse(Line As ThreadLine)
  428. 'You can use this event to unload child objects:
  429. 'Set Line.object.Children = Nothing
  430. 'Keep your memory tidy!
  431. End Sub
  432. Private Sub ThreadView1_HeaderClick(Column As ThreadViewAX.Column)
  433. With ThreadView1
  434.     If .SortColumn = Column.Index Then
  435.         .SortOrder = Abs(Not CBool(.SortOrder))
  436.       Else
  437.         .SortColumn = Column.Index
  438.     End If
  439. End With
  440. End Sub
  441. Private Sub ThreadView1_HeaderMouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  442. Dim i As Integer, lngWidth As Long
  443. If (Button And vbRightButton) = vbRightButton Then
  444.     'determines which column header was pressed
  445.     For i = 1 To ThreadView1.Columns.Count
  446.         lngWidth = lngWidth + ThreadView1.Columns(i).Width
  447.         If lngWidth >= X Then
  448.             lngCurSect = i
  449.             Exit For
  450.         End If
  451.     Next i
  452.     PopupMenu mnuHeader, vbPopupMenuRightButton
  453. End If
  454. End Sub
  455. Private Sub ThreadView1_ItemClick(Line As ThreadLine)
  456. If TabStrip1.SelectedItem.Key = "Discussions" Then
  457.     Text1 = Line.object.Message
  458. End If
  459. End Sub
  460. Private Sub ThreadView1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  461. If Button And vbRightButton Then
  462.     If ThreadView1.SelectedItem.object.HasChildren Then
  463.         mnuExpand.Enabled = Not ThreadView1.SelectedItem.Expanded
  464.         mnuCollapse.Enabled = ThreadView1.SelectedItem.Expanded
  465.       Else
  466.         mnuExpand.Enabled = False
  467.         mnuCollapse.Enabled = False
  468.     End If
  469.     PopupMenu mnuPopup
  470. End If
  471. End Sub
  472.